/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AppsUI.java
 *
 * Created on 11 Apr, 2011, 8:24:30 AM
 */
package bulkmailer.app.ui;

import bulkmailer.app.main.UI;
import bulkmailer.beans.AccountSettings;
import bulkmailer.beans.Email;
import bulkmailer.beans.EmailAddress;
import bulkmailer.beans.ServerSettings;
import bulkmailer.db.DBConnector;
import bulkmailer.email.addr.manager.EMailAddressManager;
import bulkmailer.email.msg.manager.EmailMsgManager;
//import bulkmailer.logger.BMLogger;
import bulkmailer.email.scanner.ScannerThread;
import bulkmailer.email.sender.MailSender;
import java.awt.event.ItemEvent;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.TreeSet;
import java.util.Vector;

import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import org.apache.log4j.Logger;

/**
 *
 * @author ravi
 */
public class AppsUI extends javax.swing.JFrame {

    /** Creates new form AppsUI */
    public AppsUI() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        protocolGroup = new javax.swing.ButtonGroup();
        buttonGroup1 = new javax.swing.ButtonGroup();
        mailSenderTabbedPane = new javax.swing.JTabbedPane();
        mailSender = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        sendToSpecific = new javax.swing.JRadioButton();
        jRadioButton6 = new javax.swing.JRadioButton();
        jSpinner1 = new javax.swing.JSpinner();
        mailSentProgress = new javax.swing.JProgressBar();
        jScrollPane5 = new javax.swing.JScrollPane();
        multiSelect = new javax.swing.JList();
        jPanel7 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        loginId = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        passwd = new javax.swing.JPasswordField();
        jLabel19 = new javax.swing.JLabel();
        smtpAddress = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        smtpPort = new javax.swing.JSpinner();
        jLabel23 = new javax.swing.JLabel();
        authTypeCombo = new javax.swing.JComboBox();
        jLabel22 = new javax.swing.JLabel();
        senderNameTxtBox = new javax.swing.JTextField();
        sendMail = new javax.swing.JButton();
        pauseSending = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        mailTable = new javax.swing.JTable();
        accoutSettings = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        emailTxt = new javax.swing.JTextField();
        passwordTxt = new javax.swing.JPasswordField();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jLabel4 = new javax.swing.JLabel();
        imapTxt = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        portTxt = new javax.swing.JSpinner();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        radioSsl = new javax.swing.JRadioButton();
        jRadioButton4 = new javax.swing.JRadioButton();
        jRadioButton5 = new javax.swing.JRadioButton();
        jLabel8 = new javax.swing.JLabel();
        folderTxt = new javax.swing.JTextField();
        allFolderCheckBox = new javax.swing.JCheckBox();
        fetchBtn = new javax.swing.JButton();
        clearBtn = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        totalMsgLbl = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        fetchLbl = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        uniqueLbl = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        allLbl = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();
        jLabel10 = new javax.swing.JLabel();
        folderLbl = new javax.swing.JLabel();
        pauseBtn = new javax.swing.JButton();
        dbBrowserTab = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        msgIdTxt = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        subjectTxtBox = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        bodyTxtBox = new javax.swing.JTextArea();
        jLabel21 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        signTxtBox = new javax.swing.JTextArea();
        attchBtn = new javax.swing.JButton();
        attachTxtBox = new javax.swing.JTextField();
        mailDescTextbox = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel25 = new javax.swing.JLabel();
        jScrollPane7 = new javax.swing.JScrollPane();
        disclaimerTextArea = new javax.swing.JTextArea();
        jLabel26 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        createMailBtn = new javax.swing.JButton();
        updateMailBtn = new javax.swing.JButton();
        deleteMailBtn = new javax.swing.JButton();
        nextMailBtn = new javax.swing.JButton();
        lastMailBtn = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        browseMailBtn1 = new javax.swing.JButton();
        jPanel9 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        emailBrowserTable = new javax.swing.JTable();
        refreshDataBtn = new javax.swing.JButton();
        jPanel11 = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        domainList = new javax.swing.JList();
        okToRemove = new javax.swing.JButton();
        removeCheckBox = new javax.swing.JCheckBox();
        jLabel27 = new javax.swing.JLabel();
        domainCombo = new javax.swing.JComboBox();
        jLabel28 = new javax.swing.JLabel();
        countLbl = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Bulk Mailer");
        setMinimumSize(new java.awt.Dimension(600, 500));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        mailSenderTabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                mailSenderTabbedPaneStateChanged(evt);
            }
        });
        mailSenderTabbedPane.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                mailSenderTabbedPaneComponentResized(evt);
            }
        });

        mailSender.setPreferredSize(new java.awt.Dimension(0, 0));
        mailSender.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                mailSenderComponentShown(evt);
            }
            public void componentHidden(java.awt.event.ComponentEvent evt) {
                mailSenderComponentHidden(evt);
            }
        });
        mailSender.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                mailSenderFocusGained(evt);
            }
        });

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Send Criteria"));

        sendToSpecific.setText("Send To Specific Domain");
        sendToSpecific.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                sendToSpecificItemStateChanged(evt);
            }
        });
        sendToSpecific.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sendToSpecificActionPerformed(evt);
            }
        });

        jRadioButton6.setText("Send Multiple Copies");

        jSpinner1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        multiSelect.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "", "", "", "", "" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        multiSelect.setEnabled(false);
        multiSelect.setVisibleRowCount(6);
        jScrollPane5.setViewportView(multiSelect);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
                    .addComponent(sendToSpecific)
                    .addComponent(mailSentProgress, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                        .addComponent(jRadioButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addComponent(sendToSpecific)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButton6)
                    .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(mailSentProgress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Send Settings"));

        jLabel17.setText("Email ID");

        loginId.setBackground(new java.awt.Color(254, 254, 254));

        jLabel18.setText("Password");

        passwd.setBackground(new java.awt.Color(254, 254, 254));

        jLabel19.setText("Smtp Server");

        smtpAddress.setBackground(new java.awt.Color(254, 254, 254));

        jLabel20.setText("Port");

        jLabel23.setText("Auth type");

        authTypeCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "PLAIN", "SSL/TLS" }));
        authTypeCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                authTypeComboActionPerformed(evt);
            }
        });

        jLabel22.setText("Sender Name");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel17)
                    .addComponent(jLabel18))
                .addGap(22, 22, 22)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(passwd)
                    .addComponent(loginId, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19)
                    .addComponent(jLabel22))
                .addGap(24, 24, 24)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(senderNameTxtBox, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel20)
                        .addGap(12, 12, 12)
                        .addComponent(smtpPort, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(authTypeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(smtpAddress, javax.swing.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(loginId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(smtpAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passwd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18)
                    .addComponent(senderNameTxtBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(authTypeCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23)
                    .addComponent(smtpPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel20))
                .addContainerGap())
        );

        sendMail.setText("Send Now");
        sendMail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sendMailActionPerformed(evt);
            }
        });

        pauseSending.setText("Pause");

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Mail Messages")));

        mailTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"0", "test mail", "...", "...", "...", "...", new Integer(0)}
            },
            new String [] {
                "Msg ID", "Description", "Subject", "Body", "Sign", "Sent On", "Copies"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        mailTable.setName("Mail Messages"); // NOI18N
        mailTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(mailTable);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 676, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 324, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout mailSenderLayout = new javax.swing.GroupLayout(mailSender);
        mailSender.setLayout(mailSenderLayout);
        mailSenderLayout.setHorizontalGroup(
            mailSenderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mailSenderLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mailSenderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mailSenderLayout.createSequentialGroup()
                        .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(mailSenderLayout.createSequentialGroup()
                        .addGroup(mailSenderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mailSenderLayout.createSequentialGroup()
                                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mailSenderLayout.createSequentialGroup()
                                .addComponent(pauseSending, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(sendMail, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(8, 8, 8)))
                        .addGap(10, 10, 10))))
        );
        mailSenderLayout.setVerticalGroup(
            mailSenderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mailSenderLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(mailSenderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mailSenderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sendMail)
                    .addComponent(pauseSending, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18))
        );

        mailSenderTabbedPane.addTab("Mail Sender", mailSender);
        mailSender.getAccessibleContext().setAccessibleName("mailSenderTab");

        accoutSettings.setPreferredSize(new java.awt.Dimension(840, 600));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), " Account Details ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(15, 22, 20))); // NOI18N
        jPanel1.setForeground(new java.awt.Color(1, 1, 1));

        jLabel1.setText("Email ID");

        jLabel2.setText("Password");

        emailTxt.setBackground(new java.awt.Color(254, 254, 254));

        passwordTxt.setBackground(new java.awt.Color(254, 254, 254));
        passwordTxt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                passwordTxtActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(emailTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE)
                    .addComponent(passwordTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 648, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(emailTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passwordTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(43, 43, 43))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), " Server Settings "));

        jLabel3.setText("Server Type");

        protocolGroup.add(jRadioButton1);
        jRadioButton1.setSelected(true);
        jRadioButton1.setText("imap");

        protocolGroup.add(jRadioButton2);
        jRadioButton2.setText("pop3");

        jLabel4.setText("Address");

        imapTxt.setBackground(new java.awt.Color(254, 254, 254));
        imapTxt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                imapTxtActionPerformed(evt);
            }
        });

        jLabel5.setText("Port");

        portTxt.setModel(new javax.swing.SpinnerNumberModel(Long.valueOf(0L), Long.valueOf(0L), Long.valueOf(10000L), Long.valueOf(1L)));

        jLabel6.setText("e.g. 993 for imap on gmail");

        jLabel7.setText("Authentication");

        buttonGroup1.add(radioSsl);
        radioSsl.setText("SSL");

        buttonGroup1.add(jRadioButton4);
        jRadioButton4.setText("Plain Text");

        buttonGroup1.add(jRadioButton5);
        jRadioButton5.setText("TLS");

        jLabel8.setText("Folder");

        folderTxt.setBackground(new java.awt.Color(254, 254, 254));

        allFolderCheckBox.setText("All folders");
        allFolderCheckBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                allFolderCheckBoxItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8))
                .addGap(24, 24, 24)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jRadioButton1)
                        .addGap(62, 62, 62)
                        .addComponent(jRadioButton2))
                    .addComponent(imapTxt, javax.swing.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(radioSsl)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jRadioButton5))
                            .addComponent(portTxt, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(folderTxt, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE))
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addComponent(jLabel6))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(28, 28, 28)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(allFolderCheckBox)
                                    .addComponent(jRadioButton4))))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jRadioButton1)
                    .addComponent(jRadioButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(imapTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(portTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(radioSsl)
                    .addComponent(jRadioButton5)
                    .addComponent(jRadioButton4))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(folderTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(allFolderCheckBox))
                .addContainerGap(161, Short.MAX_VALUE))
        );

        fetchBtn.setText("Get Emails");
        fetchBtn.setActionCommand("Start Fetching");
        fetchBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fetchBtnActionPerformed(evt);
            }
        });

        clearBtn.setText("Clear All");

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Status"));

        jLabel9.setText("Total Messages");

        totalMsgLbl.setText("0");

        jLabel11.setText("Fetching");

        fetchLbl.setText("0");

        jLabel13.setText("Unique ids");

        uniqueLbl.setText("0");

        jLabel15.setText("All Ids");

        allLbl.setText("0");

        jLabel10.setText("Folder Name");

        folderLbl.setText("--/--");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(jLabel11)
                            .addComponent(jLabel13)
                            .addComponent(jLabel15)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(folderLbl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(allLbl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(uniqueLbl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(fetchLbl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(totalMsgLbl, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE)))
                    .addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(totalMsgLbl)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(fetchLbl))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(uniqueLbl))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(allLbl))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(folderLbl))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 281, Short.MAX_VALUE)
                .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pauseBtn.setText("Pause");
        pauseBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pauseBtnActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout accoutSettingsLayout = new javax.swing.GroupLayout(accoutSettings);
        accoutSettings.setLayout(accoutSettingsLayout);
        accoutSettingsLayout.setHorizontalGroup(
            accoutSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(accoutSettingsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(accoutSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(accoutSettingsLayout.createSequentialGroup()
                        .addGroup(accoutSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(accoutSettingsLayout.createSequentialGroup()
                        .addComponent(clearBtn)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 681, Short.MAX_VALUE)
                        .addComponent(pauseBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(fetchBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        accoutSettingsLayout.setVerticalGroup(
            accoutSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(accoutSettingsLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(accoutSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(accoutSettingsLayout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(4, 4, 4)
                .addGroup(accoutSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(clearBtn)
                    .addComponent(fetchBtn)
                    .addComponent(pauseBtn))
                .addContainerGap())
        );

        mailSenderTabbedPane.addTab("Mail Scanner", accoutSettings);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Compose Mail"));

        jLabel12.setText("Msg ID");

        msgIdTxt.setEnabled(false);

        jLabel14.setText("Subject");

        jLabel16.setText("Body");

        bodyTxtBox.setColumns(20);
        bodyTxtBox.setRows(5);
        bodyTxtBox.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
        jScrollPane4.setViewportView(bodyTxtBox);

        jLabel21.setText("Sign");

        signTxtBox.setColumns(20);
        signTxtBox.setRows(5);
        jScrollPane6.setViewportView(signTxtBox);

        attchBtn.setText("Attachment");
        attchBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                attchBtnActionPerformed(evt);
            }
        });

        mailDescTextbox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mailDescTextboxActionPerformed(evt);
            }
        });

        jLabel24.setText("Description");

        jLabel25.setText("Disclaimer");

        disclaimerTextArea.setColumns(20);
        disclaimerTextArea.setRows(5);
        jScrollPane7.setViewportView(disclaimerTextArea);

        jLabel26.setText("(Helps remember the purpose of mail)");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel24)
                        .addGap(18, 18, 18)
                        .addComponent(mailDescTextbox, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel26))
                    .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 797, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
                            .addComponent(jLabel25, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
                            .addComponent(jLabel21, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(10, 10, 10)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(subjectTxtBox, javax.swing.GroupLayout.DEFAULT_SIZE, 726, Short.MAX_VALUE)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 726, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addGap(18, 18, 18)
                                .addComponent(msgIdTxt, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                                .addComponent(attachTxtBox, javax.swing.GroupLayout.DEFAULT_SIZE, 619, Short.MAX_VALUE)
                                .addGap(18, 18, 18)
                                .addComponent(attchBtn))
                            .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 726, Short.MAX_VALUE)
                            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 726, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(msgIdTxt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(subjectTxtBox, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addGap(152, 152, 152)))
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(attachTxtBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(attchBtn)))
                    .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25))
                .addGap(18, 18, 18)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mailDescTextbox, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel24)
                    .addComponent(jLabel26))
                .addContainerGap())
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Actions"));

        createMailBtn.setText("Create");
        createMailBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                createMailBtnActionPerformed(evt);
            }
        });

        updateMailBtn.setText("Update");
        updateMailBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateMailBtnActionPerformed(evt);
            }
        });

        deleteMailBtn.setText("Delete");
        deleteMailBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteMailBtnActionPerformed(evt);
            }
        });

        nextMailBtn.setText("Next");
        nextMailBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nextMailBtnActionPerformed(evt);
            }
        });

        lastMailBtn.setText("Last");
        lastMailBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lastMailBtnActionPerformed(evt);
            }
        });

        browseMailBtn1.setText("Browse");
        browseMailBtn1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                browseMailBtn1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(updateMailBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
                    .addComponent(deleteMailBtn, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
                    .addComponent(nextMailBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
                    .addComponent(browseMailBtn1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
                    .addComponent(lastMailBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE)
                    .addComponent(createMailBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE))
                .addContainerGap())
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 134, Short.MAX_VALUE)
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addComponent(createMailBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(updateMailBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(deleteMailBtn)
                .addGap(18, 18, 18)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(browseMailBtn1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(nextMailBtn)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lastMailBtn)
                .addContainerGap(276, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout dbBrowserTabLayout = new javax.swing.GroupLayout(dbBrowserTab);
        dbBrowserTab.setLayout(dbBrowserTabLayout);
        dbBrowserTabLayout.setHorizontalGroup(
            dbBrowserTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, dbBrowserTabLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        dbBrowserTabLayout.setVerticalGroup(
            dbBrowserTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dbBrowserTabLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dbBrowserTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        mailSenderTabbedPane.addTab("Mail Wizard", dbBrowserTab);

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Email Adresses found"));

        emailBrowserTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "Email Address", "IsActive", "Last Mail Msg Sent"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane8.setViewportView(emailBrowserTable);

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 742, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE)
                .addContainerGap())
        );

        refreshDataBtn.setText("Refresh");
        refreshDataBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshDataBtnActionPerformed(evt);
            }
        });

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "All Domains "));

        jScrollPane9.setViewportView(domainList);

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addComponent(jScrollPane9, javax.swing.GroupLayout.DEFAULT_SIZE, 428, Short.MAX_VALUE)
                .addContainerGap())
        );

        okToRemove.setText("OK");
        okToRemove.setEnabled(false);
        okToRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okToRemoveActionPerformed(evt);
            }
        });

        removeCheckBox.setText("Remove email on domain");
        removeCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeCheckBoxActionPerformed(evt);
            }
        });

        jLabel27.setText("Filter Listing:");

        domainCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Select Domain" }));
        domainCombo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                domainComboMouseClicked(evt);
            }
        });
        domainCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                domainComboActionPerformed(evt);
            }
        });

        jLabel28.setText("Count:");

        countLbl.setText("0");

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jLabel28)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 380, Short.MAX_VALUE)
                                .addComponent(jLabel27)
                                .addGap(18, 18, 18)
                                .addComponent(domainCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(refreshDataBtn)
                                .addGap(6, 6, 6))
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addGap(32, 32, 32)
                                .addComponent(countLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(6, 6, 6)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addComponent(removeCheckBox)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE)
                        .addComponent(okToRemove))
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(okToRemove, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(refreshDataBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
                                .addComponent(domainCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel27)
                                .addComponent(removeCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel28)
                            .addComponent(countLbl, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20))))
        );

        mailSenderTabbedPane.addTab("DB Browser", jPanel9);

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mailSenderTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1006, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(mailSenderTabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 553, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void pauseBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pauseBtnActionPerformed
        if (evt.getSource().equals(getPauseBtn())) {
            fetchBtn.setEnabled(true);
            getPauseBtn().setEnabled(false);
        }
}//GEN-LAST:event_pauseBtnActionPerformed

    private void fetchBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fetchBtnActionPerformed
        // TODO add your handling code here:
        if (evt.getSource().equals(fetchBtn)) {

            getPauseBtn().setEnabled(true);
            ServerSettings serverSettings = new ServerSettings();
            AccountSettings accountSettings = new AccountSettings();

            if (this.emailTxt.getText().toString() == null || this.emailTxt.getText().equals("")) {
                Logger.getRootLogger().debug("email empty");
                return;
            } else {
                accountSettings.setEmailId(this.emailTxt.getText());
            }
            if (this.convertPassword(this.getPasswordTxt().getPassword()) == null || this.convertPassword(this.getPasswordTxt().getPassword()).equals("")) {
                Logger.getRootLogger().debug("password empty");
                return;
            } else {
                String password = convertPassword(getPasswordTxt().getPassword());
                accountSettings.setPassword(password);
            }

            if (this.getPortTxt().getValue().toString() == null || this.getPortTxt().getValue().toString().equals("0")) {
                Logger.getRootLogger().debug("invalid port ");
                return;
            } else {
                serverSettings.setImapPort(Integer.valueOf(this.getPortTxt().getValue().toString()));
            }

            if (this.imapTxt.getText() == null || this.imapTxt.getText().equals("")) {
                Logger.getRootLogger().debug("imap server address not specified");
                return;
            } else {
                serverSettings.setImapServerAddress(this.imapTxt.getText().toString());
            }

            if (this.getRadioSsl().isSelected() == true) {
                serverSettings.setSecureAuth(true);
            }

            if (this.allFolderCheckBox.isSelected() == false) {
                if (this.getFolderTxt().getText().toString() == null || this.getFolderTxt().getText().equals("")) {
                    Logger.getRootLogger().debug("please specify a folder name");
                    return;
                } else {
                    serverSettings.setFolderName(this.getFolderTxt().getText());
                }
            } else {
                serverSettings.setTakeAllFolders(true);
            }

            Thread thread = new ScannerThread(serverSettings, accountSettings);
            thread.start();
            fetchBtn.setEnabled(false);
        }
}//GEN-LAST:event_fetchBtnActionPerformed

    private void allFolderCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_allFolderCheckBoxItemStateChanged
        // TODO add your handling code here:
        if (evt.getStateChange() == ItemEvent.DESELECTED) {
            folderTxt.setEnabled(true);
        } else {
            folderTxt.setEnabled(false);
        }
}//GEN-LAST:event_allFolderCheckBoxItemStateChanged

    private void imapTxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imapTxtActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_imapTxtActionPerformed

    private void passwordTxtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passwordTxtActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_passwordTxtActionPerformed

    private void sendMailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendMailActionPerformed

        ServerSettings serverSettings = new ServerSettings();
        AccountSettings accountSettings = new AccountSettings();
        Email email = new Email();
        EmailMsgManager emailMsgManager = null;
        if (evt.getSource().equals(sendMail)) {
            this.getPauseSending().setEnabled(true);
            if (this.mailTable.getSelectedRow() == -1) {
                Logger.getRootLogger().debug("no mail selected");
                return;
            }
            int mailIndex = Integer.valueOf((String) (this.mailTable.getModel().getValueAt(this.mailTable.getSelectedRow(), 0)));
            emailMsgManager = new EmailMsgManager();
            email = emailMsgManager.getMailWithIndex(mailIndex);
            Logger.getRootLogger().debug(email.toString());
            if (email == null) {
                JOptionPane.showMessageDialog(null,
                        "Error obtaining the mail content from database..",
                        "",
                        JOptionPane.ERROR_MESSAGE);
            }

            if (this.authTypeCombo.getSelectedIndex() > 0) {
                serverSettings.setSecureAuth(true);
            }
            if (this.loginId.getText().toString() == null || this.loginId.getText().toString().equals("")) {
                Logger.getRootLogger().debug("login id null");
                return;
            } else {
                accountSettings.setEmailId(this.loginId.getText());
            }
            if (this.convertPassword(this.passwd.getPassword()) == null || this.convertPassword(this.passwd.getPassword()).equals("")) {
                Logger.getRootLogger().debug("password empty");
                return;
            } else {
                String password = convertPassword(getPasswd().getPassword());
                accountSettings.setPassword(password);
            }
            if (this.smtpPort.getValue().toString() == null || this.smtpPort.getValue().toString().equals("0")) {
                Logger.getRootLogger().debug("invalid port ");
                return;
            } else {
                serverSettings.setSmtpPort(Integer.valueOf(this.getSmtpPort().getValue().toString()));
            }

            if (this.smtpAddress.getText() == null || this.smtpAddress.getText().equals("")) {
                Logger.getRootLogger().debug("smtp server address not specified");
                return;
            } else {
                serverSettings.setSmtpAddress(this.smtpAddress.getText().toString());
            }
            if (this.senderNameTxtBox.getText() == null || this.senderNameTxtBox.getText().equals("")) {
                Logger.getRootLogger().debug("sender name empty");
                return;
            } else {
                accountSettings.setSenderName(this.senderNameTxtBox.getText().toString());
            }
            MailSender sender = new MailSender();
            Logger.getRootLogger().debug("starting mail sender ...");
            if (this.sendToSpecific.isSelected()) {
                Logger.getRootLogger().debug("sending to only selected domains");
                Object domains[] = this.multiSelect.getSelectedValues();
                TreeSet<String> domainsArray = new TreeSet<String>();
                for (Object dom : domains) {
                    domainsArray.add(dom.toString());
                    sender.sendMailToDomains(accountSettings, serverSettings, email, domainsArray);
                }
            } else {
                sender.sendMailToAll(accountSettings, serverSettings, email);
            }


        }
}//GEN-LAST:event_sendMailActionPerformed

    private void sendToSpecificItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_sendToSpecificItemStateChanged
        try {
            TreeSet<String> domains = new TreeSet<String>();
            EMailAddressManager mailPopper = new EMailAddressManager();
            domains = mailPopper.getAllDomains();
            Vector<String> domainVector = new Vector<String>();
            for (String domain : domains) {
                domainVector.add(domain);
            }
            UI.appsUi.getMultiSelect().setListData(domainVector);
            if (this.getMultiSelect().isEnabled()) {
                this.getMultiSelect().setEnabled(false);
            } else {
                this.getMultiSelect().setEnabled(true);
            }
        } catch (Exception ex) {
            Logger.getRootLogger().fatal(ex.toString());

        }
}//GEN-LAST:event_sendToSpecificItemStateChanged

    private void attchBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_attchBtnActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_attchBtnActionPerformed

    private void createMailBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createMailBtnActionPerformed
        EmailMsgManager emailMsgManager = new EmailMsgManager();
        Email email = new Email();
        email.setSubject(this.subjectTxtBox.getText());
        email.setBody(this.bodyTxtBox.getText());
        email.setSign(this.signTxtBox.getText());
        email.setDescription(this.mailDescTextbox.getText());
        email.setDisclaimer(this.disclaimerTextArea.getText());
        emailMsgManager.setMailMsg(email);
        JOptionPane.showMessageDialog(null,
                "New mail created.  ",
                "",
                JOptionPane.INFORMATION_MESSAGE);
        this.browseMailBtn1ActionPerformed(evt);
    }//GEN-LAST:event_createMailBtnActionPerformed

    private void updateMailBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateMailBtnActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_updateMailBtnActionPerformed

    private void deleteMailBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteMailBtnActionPerformed
        EmailMsgManager emailMsgManager = new EmailMsgManager();
        if (this.msgIdTxt.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null,
                    "No mail selected ",
                    "",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        int choice = JOptionPane.showConfirmDialog(null,
                "Deleting message with id " + this.msgIdTxt.getText() + "\nThis cannot be undone in future !!");
        if (choice == 0) {
            emailMsgManager.deleteEmailMsg(Integer.valueOf(this.msgIdTxt.getText()));
        }
        this.browseMailBtn1ActionPerformed(evt);
    }//GEN-LAST:event_deleteMailBtnActionPerformed

    private void nextMailBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextMailBtnActionPerformed
    }//GEN-LAST:event_nextMailBtnActionPerformed

    private void lastMailBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lastMailBtnActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_lastMailBtnActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        try {
            // TODO add your handling code here:
            Logger.getRootLogger().debug("closing database connection...");
            Connection con = DBConnector.getConnection(DBConnector.SCHEMA_NAME);
            con.close();
            Logger.getRootLogger().debug("connection closed successfully");

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null,
                    "An error occured while closing database connecton. \nEvent has been logged.... ",
                    "System Error",
                    JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_formWindowClosing

    private void browseMailBtn1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseMailBtn1ActionPerformed
        EmailMsgManager emailMsgManager = new EmailMsgManager();
        Email email = null;
        email = emailMsgManager.getLatestMail();
        if (email != null) {
            this.msgIdTxt.setText(String.valueOf(email.getMailUid()));
            this.subjectTxtBox.setText(email.getSubject());
            this.bodyTxtBox.setText(email.getBody());
            this.signTxtBox.setText(email.getSign());
            this.mailDescTextbox.setText(email.getDescription());
            this.disclaimerTextArea.setText(email.getDisclaimer());
        } else {
            JOptionPane.showMessageDialog(null,
                    "There are no mail messages in the database. \nPlease first create a message.",
                    "",
                    JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_browseMailBtn1ActionPerformed

    private void mailSenderTabbedPaneStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_mailSenderTabbedPaneStateChanged
    }//GEN-LAST:event_mailSenderTabbedPaneStateChanged

    private void mailSenderFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_mailSenderFocusGained
    }//GEN-LAST:event_mailSenderFocusGained

    private void mailSenderComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_mailSenderComponentShown

        EmailMsgManager emailMsgManager = new EmailMsgManager();
        LinkedList<Email> emailList = emailMsgManager.getAllMessages();
        Iterator iter = emailList.iterator();
        Email email = null;
        DefaultTableModel model = (DefaultTableModel) this.mailTable.getModel();
        model.getDataVector().removeAllElements();
        while (iter.hasNext()) {
            email = (Email) iter.next();
            model.addRow(new Object[]{String.valueOf(email.getMailUid()), email.getDescription(), email.getSubject(), email.getBody(), email.getSign()});
        }
    }//GEN-LAST:event_mailSenderComponentShown
    private void mailSenderComponentHidden(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_mailSenderComponentHidden
    }//GEN-LAST:event_mailSenderComponentHidden

    private void authTypeComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_authTypeComboActionPerformed
    }//GEN-LAST:event_authTypeComboActionPerformed

    private void mailDescTextboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mailDescTextboxActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_mailDescTextboxActionPerformed

    private void okToRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okToRemoveActionPerformed
        EMailAddressManager addressManager = new EMailAddressManager();
        if (this.domainList.isSelectionEmpty() == true) {
            JOptionPane.showMessageDialog(null,
                    "Select a domain to delete.",
                    "",
                    JOptionPane.INFORMATION_MESSAGE);
            return;
        }
        Object domains[] = this.domainList.getSelectedValues();
        TreeSet<String> domainsArray = new TreeSet<String>();
        for (Object dom : domains) {
            Logger.getRootLogger().debug("deleting of domain: " + dom.toString());
            domainsArray.add(dom.toString());
        }
        addressManager.deleteOnDomain(domainsArray);
        this.refreshDataBtnActionPerformed(evt);

    }//GEN-LAST:event_okToRemoveActionPerformed

    private void sendToSpecificActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendToSpecificActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_sendToSpecificActionPerformed

    private void refreshDataBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshDataBtnActionPerformed
        try {
            TreeSet<String> domains = new TreeSet<String>();
            EMailAddressManager addressManager = new EMailAddressManager();
            Logger.getRootLogger().debug("refreshing domains");
            domains = addressManager.getAllDomains();
            if (domains == null) {
                Logger.getRootLogger().error("no domains fethced from db");
            }
            Vector<String> domainVector = new Vector<String>();
            for (String domain : domains) {
                domainVector.add(domain);
            }
            UI.appsUi.domainList.setListData(domainVector);
            Logger.getRootLogger().debug("refreshing the email addresses");
            ArrayList<EmailAddress> addressList = null;
            addressList = addressManager.getAllAddressesWithStatus();
            if (addressList == null) {
                Logger.getRootLogger().error("addressList null");
            }
            populateBrowserTable(addressList);
            if (domains == null) {
                Logger.getRootLogger().error("domains object is null");
            }
            populateDomainCombo(domains);
        } catch (Exception ex) {
            ex.printStackTrace();
            Logger.getRootLogger().fatal(ex);
        }
    }//GEN-LAST:event_refreshDataBtnActionPerformed

    private void removeCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeCheckBoxActionPerformed
        if (this.removeCheckBox.isSelected()) {
            this.okToRemove.setEnabled(true);
        } else {
            this.okToRemove.setEnabled(false);
        }
    }//GEN-LAST:event_removeCheckBoxActionPerformed

    private void domainComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_domainComboActionPerformed
        String filterDomain = null;      
        Logger.getRootLogger().debug("selected index is " +domainCombo.getSelectedIndex());
        if(domainCombo.getSelectedIndex()==0){
            Logger.getRootLogger().debug("index is " +domainCombo.getSelectedIndex());
            return;
        }else{
            filterDomain = this.domainCombo.getSelectedItem().toString();
        }
        if (filterDomain.isEmpty() || filterDomain == null) {
            Logger.getRootLogger().debug("filter domain is null");
            return;
        }
        EMailAddressManager addressManager = new EMailAddressManager();
        ArrayList<EmailAddress> addressList = null;
        addressList = addressManager.getAllAddressesWithStatus(filterDomain);
        populateBrowserTable(addressList);
    }//GEN-LAST:event_domainComboActionPerformed

    private void domainComboMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_domainComboMouseClicked
    }//GEN-LAST:event_domainComboMouseClicked

    private void mailSenderTabbedPaneComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_mailSenderTabbedPaneComponentResized
        // TODO add your handling code here:
    }//GEN-LAST:event_mailSenderTabbedPaneComponentResized

    public String convertPassword(char[] cPassword) {
        String strRet = "";
        for (int i = 0; i < cPassword.length; i++) {
            strRet += cPassword[i];
        }
        return strRet;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel accoutSettings;
    private javax.swing.JCheckBox allFolderCheckBox;
    private javax.swing.JLabel allLbl;
    private javax.swing.JTextField attachTxtBox;
    private javax.swing.JButton attchBtn;
    private javax.swing.JComboBox authTypeCombo;
    private javax.swing.JTextArea bodyTxtBox;
    private javax.swing.JButton browseMailBtn1;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton clearBtn;
    private javax.swing.JLabel countLbl;
    private javax.swing.JButton createMailBtn;
    private javax.swing.JPanel dbBrowserTab;
    private javax.swing.JButton deleteMailBtn;
    private javax.swing.JTextArea disclaimerTextArea;
    private javax.swing.JComboBox domainCombo;
    private javax.swing.JList domainList;
    private javax.swing.JTable emailBrowserTable;
    private javax.swing.JTextField emailTxt;
    private javax.swing.JButton fetchBtn;
    private javax.swing.JLabel fetchLbl;
    private javax.swing.JLabel folderLbl;
    private javax.swing.JTextField folderTxt;
    private javax.swing.JTextField imapTxt;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton4;
    private javax.swing.JRadioButton jRadioButton5;
    private javax.swing.JRadioButton jRadioButton6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSpinner jSpinner1;
    private javax.swing.JButton lastMailBtn;
    private javax.swing.JTextField loginId;
    private javax.swing.JTextField mailDescTextbox;
    private javax.swing.JPanel mailSender;
    private javax.swing.JTabbedPane mailSenderTabbedPane;
    private javax.swing.JProgressBar mailSentProgress;
    private javax.swing.JTable mailTable;
    private javax.swing.JTextField msgIdTxt;
    private javax.swing.JList multiSelect;
    private javax.swing.JButton nextMailBtn;
    private javax.swing.JButton okToRemove;
    private javax.swing.JPasswordField passwd;
    private javax.swing.JPasswordField passwordTxt;
    private javax.swing.JButton pauseBtn;
    private javax.swing.JButton pauseSending;
    private javax.swing.JSpinner portTxt;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.ButtonGroup protocolGroup;
    private javax.swing.JRadioButton radioSsl;
    private javax.swing.JButton refreshDataBtn;
    private javax.swing.JCheckBox removeCheckBox;
    private javax.swing.JButton sendMail;
    private javax.swing.JRadioButton sendToSpecific;
    private javax.swing.JTextField senderNameTxtBox;
    private javax.swing.JTextArea signTxtBox;
    private javax.swing.JTextField smtpAddress;
    private javax.swing.JSpinner smtpPort;
    private javax.swing.JTextField subjectTxtBox;
    private javax.swing.JLabel totalMsgLbl;
    private javax.swing.JLabel uniqueLbl;
    private javax.swing.JButton updateMailBtn;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the totalMsgLbl
     */
    public javax.swing.JLabel getTotalMsgLbl() {
        return totalMsgLbl;
    }

    /**
     * @param totalMsgLbl the totalMsgLbl to set
     */
    public void setTotalMsgLbl(int count) {
        this.totalMsgLbl.setText("" + count);
    }

    /**
     * @return the allLbl
     */
    public javax.swing.JLabel getAllLbl() {
        return allLbl;
    }

    /**
     * @param allLbl the allLbl to set
     */
    public void setAllLbl(int count) {
        this.allLbl.setText("" + count);
    }

    /**
     * @return the fetchLbl
     */
    public javax.swing.JLabel getFetchLbl() {
        return fetchLbl;
    }

    /**
     * @param fetchLbl the fetchLbl to set
     */
    public void setFetchLbl(int count) {
        this.getFetchLbl().setText("" + count);
    }

    /**
     * @return the folderTxt
     */
    public javax.swing.JTextField getFolderTxt() {
        return folderTxt;
    }

    /**
     * @param folderTxt the folderTxt to set
     */
    public void setFolderTxt(javax.swing.JTextField folderTxt) {
        this.folderTxt = folderTxt;
    }

    /**
     * @return the uniqueLbl
     */
    public javax.swing.JLabel getUniqueLbl() {
        return uniqueLbl;
    }

    /**
     * @param uniqueLbl the uniqueLbl to set
     */
    public void setUniqueLbl(int count) {
        this.uniqueLbl.setText("" + count);
    }

    /**
     * @return the progressBar
     */
    public javax.swing.JProgressBar getProgressBar() {
        return progressBar;
    }

    /**
     * @param progressBar the progressBar to set
     */
    public void setProgressBar(javax.swing.JProgressBar progressBar) {
        this.progressBar = progressBar;
    }


    
    /**
     * @param fetchLbl the fetchLbl to set
     */
    public void setFetchLbl(javax.swing.JLabel fetchLbl) {
        this.fetchLbl = fetchLbl;
    }

    /**
     * @return the folderLbl
     */
    public javax.swing.JLabel getFolderLbl() {
        return folderLbl;
    }

    /**
     * @param folderLbl the folderLbl to set
     */
    public void setFolderLbl(javax.swing.JLabel folderLbl) {
        this.folderLbl = folderLbl;
    }

    /**
     * @return the loginId
     */
    public javax.swing.JTextField getLoginId() {
        return loginId;
    }

    /**
     * @param loginId the loginId to set
     */
    public void setLoginId(javax.swing.JTextField loginId) {
        this.loginId = loginId;
    }

    /**
     * @return the mailSender
     */
    public javax.swing.JPanel getMailSender() {
        return mailSender;
    }

    /**
     * @param mailSender the mailSender to set
     */
    public void setMailSender(javax.swing.JPanel mailSender) {
        this.mailSender = mailSender;
    }

    /**
     * @return the passwd
     */
    public javax.swing.JPasswordField getPasswd() {
        return passwd;
    }

    /**
     * @param passwd the passwd to set
     */
    public void setPasswd(javax.swing.JPasswordField passwd) {
        this.passwd = passwd;
    }

    /**
     * @return the passwordTxt
     */
    public javax.swing.JPasswordField getPasswordTxt() {
        return passwordTxt;
    }

    /**
     * @param passwordTxt the passwordTxt to set
     */
    public void setPasswordTxt(javax.swing.JPasswordField passwordTxt) {
        this.passwordTxt = passwordTxt;
    }

    /**
     * @return the pauseBtn
     */
    public javax.swing.JButton getPauseBtn() {
        return pauseBtn;
    }

    /**
     * @param pauseBtn the pauseBtn to set
     */
    public void setPauseBtn(javax.swing.JButton pauseBtn) {
        this.pauseBtn = pauseBtn;
    }

    /**
     * @return the pauseSending
     */
    public javax.swing.JButton getPauseSending() {
        return pauseSending;
    }

    /**
     * @param pauseSending the pauseSending to set
     */
    public void setPauseSending(javax.swing.JButton pauseSending) {
        this.pauseSending = pauseSending;
    }

    /**
     * @return the portTxt
     */
    public javax.swing.JSpinner getPortTxt() {
        return portTxt;
    }

    /**
     * @param portTxt the portTxt to set
     */
    public void setPortTxt(javax.swing.JSpinner portTxt) {
        this.portTxt = portTxt;
    }

    /**
     * @return the radioSsl
     */
    public javax.swing.JRadioButton getRadioSsl() {
        return radioSsl;
    }

    /**
     * @param radioSsl the radioSsl to set
     */
    public void setRadioSsl(javax.swing.JRadioButton radioSsl) {
        this.radioSsl = radioSsl;
    }

    /**
     * @return the sendMail
     */
    public javax.swing.JButton getSendMail() {
        return sendMail;
    }

    /**
     * @param sendMail the sendMail to set
     */
    public void setSendMail(javax.swing.JButton sendMail) {
        this.sendMail = sendMail;
    }

    public javax.swing.JTextField getSmtpAddress() {
        return smtpAddress;
    }

    /**
     * @param smtpAddress the smtpAddress to set
     */
    public void setSmtpAddress(javax.swing.JTextField smtpAddress) {
        this.smtpAddress = smtpAddress;
    }

    /**
     * @return the smtpPort
     */
    public javax.swing.JSpinner getSmtpPort() {
        return smtpPort;
    }

    /**
     * @param smtpPort the smtpPort to set
     */
    public void setSmtpPort(javax.swing.JSpinner smtpPort) {
        this.smtpPort = smtpPort;
    }

    /**
     * @return the multiSelect
     */
    public javax.swing.JList getMultiSelect() {
        return multiSelect;
    }

    /**
     * @param multiSelect the multiSelect to set
     */
    public void setMultiSelect(javax.swing.JList multiSelect) {
        this.multiSelect = multiSelect;
    }

    /**
     * @return the mailSentProgress
     */
    public javax.swing.JProgressBar getMailSentProgress() {
        return mailSentProgress;
    }

    /**
     * @param mailSentProgress the mailSentProgress to set
     */
    public void setMailSentProgress(javax.swing.JProgressBar mailSentProgress) {
        this.mailSentProgress = mailSentProgress;
    }
    public int sentMailCount = 0;

    public void markMailSentProgress() {
        this.mailSentProgress.setValue(sentMailCount++);

    }

    private void populateBrowserTable(ArrayList<EmailAddress> addressList) {
        DefaultTableModel model = (DefaultTableModel) this.emailBrowserTable.getModel();
        if (model == null) {
            Logger.getRootLogger().error("model null");
        }
        model.getDataVector().removeAllElements();
        for (EmailAddress ea : addressList) {
            Logger.getRootLogger().debug(ea.getEmailAddress());
            model.addRow(new Object[]{String.valueOf(ea.getEmailAddress()), ea.getStatus(), String.valueOf(ea.getLastMailSent())});
        }
        this.countLbl.setText(String.valueOf(addressList.size()));
    }

    private void populateDomainCombo(TreeSet<String> domains) {
        Logger.getRootLogger().debug("populating domain combo");
        Logger.getRootLogger().debug(domainCombo.getItemCount());        
        while(domainCombo.getItemCount()>1){
            domainCombo.removeItemAt(1);
        }
        for (String d : domains) {
            domainCombo.addItem(d.toString());
        }

    }
}
